package com.starhub.web.host.impl;

import java.util.Arrays;
import java.util.List;

import org.springframework.http.ResponseEntity;

import com.starhub.web.host.ProductHost;
import com.starhub.web.host.StarHubBaseHost;
import com.starhub.web.model.ProductCarousel;
import com.starhub.web.model.Tile;

public class ProductHostImpl extends StarHubBaseHost implements ProductHost {

	public List<ProductCarousel> getProductCarousels(int categoryId) {
		ResponseEntity<ProductCarousel[]> response = restTemplate.getForEntity("http://localhost:8080/StarHub/getProductCarousel?categoryId=" + String.valueOf(categoryId), ProductCarousel[].class);
		return Arrays.asList(response.getBody());
	}

	public ProductCarousel getProducCarouselDetails(int productId) {
		return restTemplate.getForObject("http://localhost:8080/StarHub/getProducCarouselDetails?productId=" + String.valueOf(productId), ProductCarousel.class);
	}

	public void updateProductCarousel(ProductCarousel productCarousel) {
		restTemplate.postForObject("http://localhost:8080/StarHub/updateProductCarousel", productCarousel, Tile.class);
	}
}
